//
//  XHSplashListViewController.m
//  XHAdSDKTest
//
//  Created by 陈俭红 on 2022/2/15.
//

#import "XHSplashListViewController.h"

//广告头文件
#import <XHAdSDK/XHAdSDK.h>

@interface XHSplashListViewController ()<XHSplashAdDelegate>

@property (nonatomic, strong)UIButton * normalBtn;
/* <#name#> */
@property (nonatomic, strong) XHAdCenter *center;
@end

@implementation XHSplashListViewController

//MARK: Cycle Methods
- (void)viewDidLoad{
    [super viewDidLoad];
    
    self.title = @"开屏广告";
    
    [self addAllViews];
}

//MARK: Custom Methods
- (void)addAllViews{
    [self.view addSubview:self.normalBtn];
}

//MARK: Getter Methods
- (UIButton *)normalBtn{
    if (!_normalBtn) {
        _normalBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _normalBtn.frame = CGRectMake((self.view.frame.size.width - 150) / 2, 100, 150, 44);
        [_normalBtn setTitle:@"开屏广告" forState:UIControlStateNormal];
        [_normalBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _normalBtn.backgroundColor = [UIColor purpleColor];
        [_normalBtn addTarget:self action:@selector(playBtnAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return _normalBtn;
}

- (void)playBtnAction{
    XHAdCenter * center = [XHAdCenter new];
    XHSplashAdData * data = [XHSplashAdData new];
    data.splashDelegate = self;
    data.timeoutInterval = 3;
    data.isPreload = YES;   //是否预加载 默认NO
    [center xh_showSplashAd:data];
    self.center = center;
    
}

- (void)xh_onSplashAdDidLoad {
    NSLog(@"广告预加载成功");
    [self.center xh_showPreloadSplashAd];
}

/** 广告加载失败，msg加载失败说明（如果重新请求广告，注意：只重新请求一次）*/
- (void)xh_onSplashAdFail:(NSString *)errorString{
    
}

/** 广告渲染成功 */
- (void)xh_onSplashAdExposure{
    
}

/** 广告被点击 */
- (void)xh_onSplashAdClicked{
    
}

/** 广告被跳过 */
- (void)xh_onSplashAdClose{
    
}

/** 广告结束(跳过或者倒计时结束调用) */
- (void)xh_onSplashAdFinish {
    NSLog(@"广告结束 ====");
}

@end
